package com.qunduikj.sjb.sdk.model.enums;

/**
 * Created by litao on 2015/12/1.
 */
public enum AccountIncomeType {

    // 利用构造函数传参  "运费", "运费", "运费", "其他收入"
    RoadToll(1, "运费"), AddCheer(2, "运费"), CarUpkeep(3, "运费"), ViolationMoney(4, "其他收入");

    // 定义私有变量
    private int code;
    private String description;
    // 构造函数，枚举类型只能为私有

    AccountIncomeType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public AccountIncomeType setCode(int code) {
        this.code = code;
        return this;
    }

    public String getDescription() {
        return description;
    }

    public AccountIncomeType setDescription(String description) {
        this.description = description;
        return this;
    }

    @Override
    public String toString() {
        return "AccountIncomeType{" +
                "code=" + code +
                ", type='" + description + '\'' +
                '}';
    }

    public static AccountIncomeType getByCode(int type) {
        AccountIncomeType cartype[] = AccountIncomeType.values();
        for (int i = 0; i < cartype.length; i++) {
            AccountIncomeType pw = cartype[i];
            if (pw.getCode() == type) {
                return pw;
            }
        }
        return AccountIncomeType.ViolationMoney;
    }


}
